package com.github.myGenerator.generator;

import cn.org.rapid_framework.generator.GeneratorFacade;

import javax.persistence.Table;
import java.util.List;

/**
 * Created by Ztt on 2016/8/28.
 */
public class MyGeneratorFacade extends GeneratorFacade {

    public MyGeneratorFacade(){
        super();
    }

    /**
     * 根据Class生成文件,模板引用的变量名称为: clazz 实体类为:
     * cn.org.rapid_framework.generator.provider.java.model.JavaClass
     */
    public void generateByClass(List<Class<?>> clazzes) throws Exception {
        for (Class clazz : clazzes) {
            new ProcessUtils().processByClass(clazz, false);
        }
    }

    /**
     * 根据Table生成文件,模板引用的变量名称为: table, 实体类为: @see
     * cn.org.rapid_framework.generator.provider.db.table.model.Table
     *
     * @throws Exception
     */
    public void generateByTable(List<Class<?>> clazzes) throws Exception {
        for(Class clazz : clazzes){
            Table table = (Table) clazz.getAnnotation(Table.class);
            new ProcessUtils().processByTable(table.name(), false);
        }
    }
}
